//
//  SetingViewController.m
//  WallpaperHdLib
//
//  Created by 9haomi on 2021/3/1.
//

#import "SetingViewController.h"
#import "SetingTableViewCell.h"

@interface SetingViewController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong) UITableView *table;
@end

@implementation SetingViewController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = YES;
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    [self addUI];
}
- (void)addUI
{
    

    self.table = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain];
    self.table.delegate = self;
    self.table.dataSource = self;
    self.table.estimatedRowHeight = 60;
    self.table.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.table.tableFooterView = [[UIView alloc] init];
    self.table.backgroundColor = [UIColor clearColor];
    [self.table registerNib:[UINib nibWithNibName:@"SetingTableViewCell" bundle:nil] forCellReuseIdentifier:@"SetingTableViewCell"];
    [self.view addSubview:self.table];
    if (@available(iOS 11.0, *)) {
        self.table.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }
    
    [self.table mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(kSafeAreaTopHeight+20);
        make.bottom.equalTo(self.view).offset(0-80);
        make.left.equalTo(self.view);
        make.right.equalTo(self.view);
    }];
    
}

- (IBAction)clickBacnBtn:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
    [self dismissViewControllerAnimated:YES completion:nil];
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

    return 5;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    return [UIView new];
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0.001;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 56;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *TableSampleIdentifier = @"SetingTableViewCell";
    SetingTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:TableSampleIdentifier];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle]loadNibNamed:@"SetingTableViewCell" owner:nil options:nil]objectAtIndex:1];
    }
    cell.accessoryType = UITableViewCellAccessoryNone;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    switch (indexPath.row) {
        case 0:
            cell.nameLabel.text = NSLocalizedString(@"feedback", @"feedback");
            break;
        case 1:
            cell.nameLabel.text = NSLocalizedString(@"aboutus", @"aboutus");
            break;
        case 2:
            cell.nameLabel.text = NSLocalizedString(@"useragreement", @"useragreement");
            break;
        case 3:
            cell.nameLabel.text = NSLocalizedString(@"privacypolicy", @"privacypolicy");
            break;
        case 4:
            cell.nameLabel.text = NSLocalizedString(@"clearCaches", @"clearCaches");
            break;
        default:
            break;
    }
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
}

@end
